package com.qyer.search.model.mutable;

import org.apache.commons.collections4.MapUtils;

import java.util.HashMap;
import java.util.Map;

/**
 * Created by tangzheng on 16/8/10.
 */
public class DoubleFaceMap {
  private Map<Integer, String> obverseDict;
  private Map<String, Integer> reverseDict;

  public DoubleFaceMap(Map<Integer, String> obverseDict, Map<String, Integer> reverseDict) {
    this.obverseDict = obverseDict;
    this.reverseDict = reverseDict;
  }

  public DoubleFaceMap() {
    obverseDict = new HashMap<>();
    reverseDict = new HashMap<>();
  }

  public boolean isEmpty(){
    if(MapUtils.isEmpty(obverseDict) || MapUtils.isEmpty(reverseDict))
      return true;
    return false;
  }

  public Map<Integer, String> getObverseDict() {
    return obverseDict;
  }

  public void setObverseDict(Map<Integer, String> obverseDict) {
    this.obverseDict = obverseDict;
  }

  public Map<String, Integer> getReverseDict() {
    return reverseDict;
  }

  public void setReverseDict(Map<String, Integer> reverseDict) {
    this.reverseDict = reverseDict;
  }

  @Override public boolean equals(Object o) {
    if (this == o)
      return true;
    if (o == null || getClass() != o.getClass())
      return false;

    DoubleFaceMap that = (DoubleFaceMap) o;

    if (!obverseDict.equals(that.obverseDict))
      return false;
    return reverseDict.equals(that.reverseDict);

  }

  @Override public int hashCode() {
    int result = obverseDict.hashCode();
    result = 31 * result + reverseDict.hashCode();
    return result;
  }

  @Override public String toString() {
    return "DoubleFaceMap{" +
      "reverseDict=" + reverseDict +
      ", obverseDict=" + obverseDict +
      '}';
  }
}
